'use strict';

module.exports = function createUpdatedCollection(collectionA, objectB) {
  let arr=[];
  let result={};
 for(let i of collectionA)
  {
    if(i.length!=1)
    {
      let arr1=i.split("");
      result[arr1[0]]={};
      result[arr1[0]].key=arr1[0];
      result[arr1[0]].count=parseInt(arr1[2]);
    }
    else
    {
      if(!result[i])
      {
        result[i]={};
        result[i].key=i;
        result[i].count=1;
      }
      else
        result[i].count++;
    }
}
    //console.log(result);
 for(let j in result)
    arr.push(result[j]);
   // console.log(arr);


   for(let m of  arr)
   {
     for(let n of objectB.value)
     {
       if(m.key==n)
       m.count=m.count-(Math.floor((m.count/3)));
     }
    }



    return arr;
}
